<template>
  <div class="dashboard-editor-container">
    <template v-if="!isMerchant">
      <div class="title">活动订单</div>
      <el-row :gutter="40" class="panel-group">
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-badge :hidden="!eventsData.toBePaidNum" :value="eventsData.toBePaidNum">
                <el-icon :size="48"><ICONS.ScaleToOriginal /></el-icon>
              </el-badge>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">待支付</div>
              <div style="font-size: 20px">
                {{ eventsData.toBePaidNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-icon :size="48"><ICONS.DocumentChecked /></el-icon>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">已支付</div>
              <div style="font-size: 20px">
                {{ eventsData.tobeUsedNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-badge :hidden="!eventsData.inRefundNum" :value="eventsData.inRefundNum">
                <el-icon :size="48"><ICONS.Timer /></el-icon>
              </el-badge>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">退款中</div>
              <div style="font-size: 20px">
                {{ eventsData.inRefundNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-icon :size="48"><ICONS.Select /></el-icon>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">已完成</div>
              <div style="font-size: 20px">
                {{ eventsData.completedNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-icon :size="48"><ICONS.CloseBold /></el-icon>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">已取消</div>
              <div style="font-size: 20px">
                {{ eventsData.cancelledNum }}
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
      <div class="title">退款</div>
      <el-row :gutter="40" class="panel-group">
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
            <div class="card-panel">
              <div class="card-panicon-wrapper">
                <el-badge :hidden="!refundData.toBeCheckNum" :value="refundData.toBeCheckNum">
                  <el-icon :size="48"><ICONS.Warning /></el-icon>
                </el-badge>
              </div>
              <div class="card-panel-description">
                <div class="card-panel-text">待业务审核</div>
                <div style="font-size: 20px">
                  {{ refundData.toBeCheckNum }}
                </div>
              </div>
            </div>
          </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-badge :hidden="!refundData.toBeExamineNum" :value="refundData.toBeExamineNum">
                <el-icon :size="48"><ICONS.Warning /></el-icon>
              </el-badge>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">待财务审核</div>
              <div style="font-size: 20px">
                {{ refundData.toBeExamineNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-badge :hidden="!refundData.inRefundNum" :value="refundData.inRefundNum">
                <el-icon :size="48"><ICONS.CircleCheck /></el-icon>
              </el-badge>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">退款中</div>
              <div style="font-size: 20px">
                {{ refundData.inRefundNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-icon :size="48"><ICONS.QuestionFilled /></el-icon>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">已驳回</div>
              <div style="font-size: 20px">
                {{ refundData.rejectedNum }}
              </div>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
          <div class="card-panel">
            <div class="card-panicon-wrapper">
              <el-icon :size="48"><ICONS.CircleClose /></el-icon>
            </div>
            <div class="card-panel-description">
              <div class="card-panel-text">退款失败</div>
              <div style="font-size: 20px">
                {{ refundData.failedNum }}
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </template>
    <template v-else>
      <h1 style="padding: 300px 100px;text-align: center;font-size: 60px">欢迎来到 品客管理后台</h1>
    </template>
  </div>
</template>

<script setup>
import { getIndexData } from "@/api/indexData";
import { ref } from "vue";
import { useStore } from "@/store";
import * as ICONS from '@element-plus/icons-vue';
const store = useStore();
const { allData,eventsData,refundData,isMerchant } = (()=>{
  const allData = ref({});
  const eventsData = ref({});
  const refundData = ref({});
  const isMerchant = ref(false)
  isMerchant.value = store.getters.userInfo?.role === '商户'
  getIndexData().then((res) => {
    if (res.code === 0) {
      console.log("data:", res);
      eventsData.value = res.data.eventsData
      refundData.value = res.data.refundData
    }
  })
  return {
    isMerchant,
    allData,
    eventsData,
    refundData
  }
})();
</script>

<style scoped lang="scss">
.dashboard-editor-container {
  padding: 12px;
  background-color: #ffffff;
  border-radius: 8px;
  >.title{
    padding: 8px 0;
  }
}
.panel-group {
  margin-top: 18px;
  .title {
    font-size: 22px;
    font-weight: bold;
    color: #666;
    height: 40px;
    margin-left: 30px;
  }
  .card-panel-col {
    margin-bottom: 32px;
  }
  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 2px 2px 8px rgb(0,0,0,15%);
    background-color: #ffffff;
    &:hover {
      background-color: #fff;
      .card-panicon-wrapper {
        color: #fff;
        background-color: #36a3f7;
      }
    }
    .card-panicon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
      color: #36a3f7;
    }
    .card-panel-icon {
      float: left;
      font-size: 48px;
    }
    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;
      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }
      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}
</style>
